import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';

interface GlobalState {
  isLoggedIn: boolean;
  username: string | null;
  login: (username: string) => void;
  logout: () => void;
}
export const useGlobalStore = create<GlobalState>()(
  immer((set) => ({
    isLoggedIn: false,
    username: null,
    login: (username: string) => set(() => ({ isLoggedIn: true, username })),
    logout: () => set(() => ({ isLoggedIn: false, username: null })),
  })),
);
